package com.neko.controller;

import com.neko.message.Result;
import com.neko.message.ResultCode;
import com.neko.order.Order;
import com.neko.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("/{id}")
    public Result getOrder(@PathVariable("id") Integer id) {

        Order order = orderService.getOrderById(id);

        Result result = new Result(ResultCode.SUCCESS,  order);

        return result;
    }
}
